package com.kedacom.emptyproject.model.net

import android.support.annotation.NonNull
import com.kedacom.emptyproject.BuildConfig
import com.kedacom.lego.fast.data.http.HttpRetrofitFactory
import okhttp3.OkHttpClient
import retrofit2.Retrofit


object HttpServicesFactory {
    private var httpRetrofitFactory: HttpRetrofitFactory

    private fun <T> createService(@NonNull clazz: Class<T>): T {
        return httpRetrofitFactory.createHttpService(clazz)
    }

    @get:Synchronized
    val httpServiceApi: HttpServiceApi
        get() = createService(HttpServiceApi::class.java)

    init {
        //init HttpRetrofitFactory
        httpRetrofitFactory =
            HttpRetrofitFactory.instance(object : HttpRetrofitFactory.Interceptor() {
                override fun baseUrl(): String {
                    return BuildConfig.HTTP_BASE_URL
                }

                override fun okHttpClient(okHttpClient: OkHttpClient.Builder) {}
                override fun retrofit(retrofit: Retrofit.Builder) {}
            })
    }
}
